package com.qfedu.yige.controller;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.qfedu.yige.pojo.Record;
import com.qfedu.yige.service.RecordService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("/select")
public class RecordController {
    @Autowired
    private RecordService recordService;

    @GetMapping("/find")
    public Record findByid(@RequestParam("rid") Integer rid){
//        Record record = recordService.getById(rid);
//        return record;
        QueryWrapper queryWrapper =new QueryWrapper();
        queryWrapper.eq ("rid",rid);
        Record one = recordService.getOne(queryWrapper);
        return one;
    }
    @RequestMapping("byUid")
    public List<Record> findByUid(@RequestParam("uid") Integer uid){
        QueryWrapper queryWrapper =new QueryWrapper();
        queryWrapper.eq("uid",uid);
        List list = recordService.list(queryWrapper);
        return list;

    }
}
